package com.medicine.sys.controller;

import com.medicine.common.base.ResponseData;
import com.medicine.sys.entity.Menu;
import com.medicine.sys.param.MenuParam;
import com.medicine.sys.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "菜单管理")
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @ApiOperation(value="菜单列表查询")
    @GetMapping("/list")
    public ResponseData list(MenuParam menuParam){
        return ResponseData.success("查询成功！",menuService.selectList(menuParam));
    }

    @ApiOperation(value="菜单新增")
    @PostMapping
    public ResponseData install(Menu menu){
        menuService.install(menu);
        return ResponseData.success("新增成功！");
    }


    @ApiOperation(value="菜单修改")
    @PutMapping
    public ResponseData update(Menu menu){
        menuService.install(menu);
        return ResponseData.success("修改成功！");
    }

    @ApiOperation(value="菜单详情查询")
    @GetMapping("/{id}")
    public ResponseData list(@PathVariable String id){
        return ResponseData.success("查询成功！",menuService.getId(id));
    }
}
